package com.solo.system.model.role;

import com.solo.system.api.entity.SysRoleMenu;
import com.solo.system.model.role.req.RoleMenuReq;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 系统角色菜单转换类
 * @author 十一
 * @since 2024/10/17
 * 人生若只如初见，何事秋风悲画扇
 **/
@Mapper
public interface SysRoleMenuConvert {

    SysRoleMenuConvert INSTANCE = Mappers.getMapper(SysRoleMenuConvert.class);

    default List<SysRoleMenu> convert(RoleMenuReq bean) {
        return bean.getMenuIds().stream().map(menuId -> {
            SysRoleMenu roleMenu = new SysRoleMenu();
            roleMenu.setRoleId(bean.getRoleId());
            roleMenu.setMenuId(menuId);
            return roleMenu;
        }).toList();
    }
}
